package com.example.mobile2021606140lhq0407;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private TextView tvMainTitle;
    private Button btnMain01;
    private TextView tvMain1;
    private RadioGroup radMain01;
    private RadioButton radMain01A;
    private RadioButton radMain01B;
    private RadioButton radMain01C;
    private RadioButton radMain01D;
    private TextView tvMain2;
    private RadioGroup radMain02;
    private RadioButton radMain02A;
    private RadioButton radMain02B;
    private RadioButton radMain02C;
    private RadioButton radMain02D;
    private TextView tvMain3;
    private RadioGroup radMain03;
    private RadioButton radMain03A;
    private RadioButton radMain03B;
    private RadioButton radMain03C;
    private RadioButton radMain03D;
    private TextView tvMain4;
    private RadioGroup radMain04;
    private RadioButton radMain04A;
    private RadioButton radMain04B;
    private RadioButton radMain04C;
    private RadioButton radMain04D;
    private Button btnMain02;
    private EditText edtTxtMain001;

    int xID,cID,vID,bID,a=0;
    String y;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();



        btnMain02.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                xID=radMain01.getCheckedRadioButtonId();
                if (xID != -1){
                    RadioButton radioButton=findViewById(xID);
                    y=radioButton.getText().toString();
                    if (y.equals("B、tint")){
                        a+=25;
                    }
                }else {
                    Log.i("radioButton","未选答案");
                }


                cID=radMain02.getCheckedRadioButtonId();
                if (cID != -1){
                    RadioButton radioButton=findViewById(cID);
                    y=radioButton.getText().toString();
                    if (y.equals("C、phoneNumber")){
                        a+=25;
                    }
                }else {
                    Log.i("radioButton","未选答案");
                }


                vID=radMain03.getCheckedRadioButtonId();
                if (vID != -1){
                    RadioButton radioButton=findViewById(vID);
                    y=radioButton.getText().toString();
                    if (y.equals("B、text")){
                        a+=25;
                    }
                }else {
                    Log.i("radioButton","未选答案");
                }


                bID=radMain04.getCheckedRadioButtonId();
                if (bID != -1){
                    RadioButton radioButton=findViewById(bID);
                    y=radioButton.getText().toString();
                    if (y.equals("B、gravity")){
                        a+=25;
                    }
                }else {
                    Log.i("radioButton","未选答案");
                }
                edtTxtMain001.setText(String.valueOf(a));
                a=0;

            }

        });


        btnMain01.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                xID=radMain01.getCheckedRadioButtonId();
                if (xID !=0){
                    RadioButton radioButton=findViewById(xID);
                    radioButton.setChecked(false);
                }else {
                    Log.i("radioButton","未选答案");
                }


                cID=radMain02.getCheckedRadioButtonId();
                if (cID !=0){
                    RadioButton radioButton=findViewById(cID);
                    radioButton.setChecked(false);
                }else {
                    Log.i("radioButton","未选答案");
                }


                vID=radMain03.getCheckedRadioButtonId();
                if (vID !=0){
                    RadioButton radioButton=findViewById(vID);
                    radioButton.setChecked(false);
                }else {
                    Log.i("radioButton","未选答案");
                }


                bID=radMain04.getCheckedRadioButtonId();
                if (bID !=0){
                    RadioButton radioButton=findViewById(bID);
                    radioButton.setChecked(false);
                }else {
                    Log.i("radioButton","未选答案");
                }
                edtTxtMain001.setText(null);
                a=0;


            }
        });
    }

    private void initView() {
        tvMainTitle = findViewById(R.id.tv_main_title);
        btnMain01 = findViewById(R.id.btn_main_01);
        tvMain1 = findViewById(R.id.tv_main_1);
        radMain01 = findViewById(R.id.rad_main_01);
        radMain01A = findViewById(R.id.rad_main_01A);
        radMain01B = findViewById(R.id.rad_main_01B);
        radMain01C = findViewById(R.id.rad_main_01C);
        radMain01D = findViewById(R.id.rad_main_01D);
        tvMain2 = findViewById(R.id.tv_main_2);
        radMain02 = findViewById(R.id.rad_main_02);
        radMain02A = findViewById(R.id.rad_main_02A);
        radMain02B = findViewById(R.id.rad_main_02B);
        radMain02C = findViewById(R.id.rad_main_02C);
        radMain02D = findViewById(R.id.rad_main_02D);
        tvMain3 = findViewById(R.id.tv_main_3);
        radMain03 = findViewById(R.id.rad_main_03);
        radMain03A = findViewById(R.id.rad_main_03A);
        radMain03B = findViewById(R.id.rad_main_03B);
        radMain03C = findViewById(R.id.rad_main_03C);
        radMain03D = findViewById(R.id.rad_main_03D);
        tvMain4 = findViewById(R.id.tv_main_4);
        radMain04 = findViewById(R.id.rad_main_04);
        radMain04A = findViewById(R.id.rad_main_04A);
        radMain04B = findViewById(R.id.rad_main_04B);
        radMain04C = findViewById(R.id.rad_main_04C);
        radMain04D = findViewById(R.id.rad_main_04D);
        btnMain02 = findViewById(R.id.btn_main_02);
        edtTxtMain001 = findViewById(R.id.edtTxt_main_001);
    }
}